import { connect, PageAllModelState, Loading } from 'umi';
import React, { useEffect } from 'react';
import { Card, Avatar } from 'antd';
import { query } from './service';

interface Props {
  pageAll: PageAllModelState;
}

const PageAll: React.FC<Props> = ({ pageAll }) => {
  const { data } = pageAll;

  useEffect(() => {
    (async () => {
      await query();
    })();
  }, []);
  return (
    <div>
      {data
        ? data.map((item: any) => (
            <Card style={{ width: 300, marginTop: 16 }}>
              <Card.Meta
                avatar={
                  <Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
                }
                title={item.cloud[0].name}
                description="这是云平台"
              />
            </Card>
          ))
        : null}
    </div>
  );
};
// export default PageAll;
// export default connect(({pageAll} {pageAll: PageAllModelState}) => ({pageAll}))(PageAll);

export default connect(
  ({ pageAll, loading }: { pageAll: PageAllModelState; loading: Loading }) => ({
    pageAll,
    loading: loading.models.myHost,
  }),
)(PageAll);
